Package money
Class SimpleMoney
java.lang.Object
money.Money
money.SimpleMoney
A simple amount of Money with its currency.
- Author:
- Kent Beck, Robert Duvall (small updates and commenting)
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleMoney
(int amount, String currency) Constructs simple money from the given amount and currency. -
Method Summary
Modifier and TypeMethodDescriptionAdds given money to this money.int
amount()
Returns only the amount of this money.currency()
Returns only the currency of this money.boolean
int
hashCode()
boolean
isZero()
Tests whether this money is zeromultiply
(int factor) Multiplies this money by the given factor.negate()
Negates this money.Subtracts given money from this money.toString()
-
Constructor Details
-
SimpleMoney
Constructs simple money from the given amount and currency.
-
-
Method Details
-
add
Description copied from class:Money
Adds given money to this money. -
subtract
Description copied from class:Money
Subtracts given money from this money. -
multiply
Description copied from class:Money
Multiplies this money by the given factor. -
negate
Description copied from class:Money
Negates this money. -
isZero
public boolean isZero()Description copied from class:Money
Tests whether this money is zero -
amount
public int amount()Returns only the amount of this money. -
currency
Returns only the currency of this money. -
equals
-
hashCode
public int hashCode() -
toString
-